package com.llb.llbliving.commodity.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;

import com.llb.common.valid.EnumValidate;
import com.llb.common.valid.SaveGroup;
import com.llb.common.valid.UpdateGroup;
import com.llb.common.valid.UpdateIsShowGroup;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;

/**
 * 家居品牌
 * 
 * @author llb
 * @email llb@gmail.com
 * @date 2025-05-02 14:43:50
 */
@Data
@TableName("commodity_brand")
public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * id
	 * 1.@NotNull(message = "修改要求指定id",groups = {UpdateGroup.class})
	 * 表示@NotNull 在UpdateGroup组生效
	 */
	@NotNull(message = "修改要求指定id",groups = {UpdateGroup.class, UpdateIsShowGroup.class})
	@Null(message = "添加不能指定id",groups = {SaveGroup.class})
	@TableId
	private Long id;
	/**
	 * 品牌名
	 */
	@NotBlank(message = "品牌名不能为空",groups = {SaveGroup.class,UpdateGroup.class})
	private String name;
	/**
	 * logo
	 */
	@NotBlank(message = "logo 不能为空", groups = {SaveGroup.class})
	@URL(message = "logo 不是一个合法的 url", groups = {SaveGroup.class, UpdateGroup.class})
	private String logo;
	/**
	 * 说明
	 */
	private String description;
	/**
	 * 显示
	 */
	@NotNull(groups = {SaveGroup.class, UpdateGroup.class,UpdateIsShowGroup.class})
	@EnumValidate(values = {0,1}, groups = {SaveGroup.class, UpdateGroup.class,UpdateIsShowGroup.class} )
	private Integer isshow;
	/**
	 * 检索首字母
	 */
	//说明 1. 添加时 必须不能为空 2 如果是修改可以不提交，保持原值, 但是如果修改时有值提交，则必须通过正则校验
	@NotBlank(groups = {SaveGroup.class})
	@Pattern(regexp="^[a-zA-Z]$",message = "检索字母必须是一个字母",
			groups = {SaveGroup.class, UpdateGroup.class})
	private String firstLetter;
	/**
	 * 排序
	 */
	@NotNull(groups = {SaveGroup.class})
	@Min(value = 0, message = "排序值要求大于等于 0"
			, groups = {SaveGroup.class, UpdateGroup.class})
	private Integer sort;

}
